package com.education.ai.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 密码加密配置类 - 使用虚拟编码器，不做实际加密
 */
@Configuration
public class PasswordEncoderConfig {
    
    @Bean
    public PasswordEncoder passwordEncoder() {
        // 返回一个不做加密的PasswordEncoder实现
        return new PasswordEncoder() {
            @Override
            public String encode(CharSequence rawPassword) {
                // 不加密，直接返回原始密码
                return rawPassword.toString();
            }

            @Override
            public boolean matches(CharSequence rawPassword, String encodedPassword) {
                // 直接比较原始密码和编码密码
                return rawPassword.toString().equals(encodedPassword);
            }
        };
    }
} 